﻿namespace MockingBird.Simulator.Management
{
    using System;
    using System.Diagnostics;
    using System.Xml;
    using System.Xml.Serialization;
    using MockingBird.Simulator.Framework.Configuration;

    public class ConfigurationFileStream : IConfigurationFileStream
    {
        public void PersistConfiguration(string fileName, HandlerConfiguration configurationData)
        {
            //string fileName = this.serviceConfigSettings.ConfigFileName;



            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(HandlerConfiguration));
                using (XmlTextWriter xtw = new XmlTextWriter(fileName, System.Text.Encoding.UTF8))
                {
                    serializer.Serialize(xtw, configurationData);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }


        }

    }
}
